#include "timer.h"

timer *timer::createTimer(node *parent, float interval)
{
    auto timer_ = new timer();
    timer_->setInterval(interval);
    if(parent) parent->addChild(timer_);
    timer_->setActive(false);
    return timer_;
}

void timer::update(float dt)
{
    time += dt;
    if(time >interval)
    {
        time = 0;
        timeOut = true;
        //callback();
    }
}

bool timer::TimeOut()
{
    if(timeOut){
        timeOut = false;
        return true;
    }
    return false;
}
